# -*- coding:utf-8 -*-
class Solution:
    def StrToInt(self, s):
        # write code here
        nums = [str(i) for i in range(10)]
        s = list(s.strip())
        flag = 1
        res = 0
        for i in range(len(s)):
            # print(res)
            if i == 0:
                if s[i] == '+':
                    flag = 1
                elif s[i] == '-':
                    flag = -1
                elif s[i] in nums:
                    res = res*10 + int(s[i])
                else:
                    return 0
            else:
                if s[i] in nums:
                    res = res * 10 + int(s[i])
                else:
                    return 0
        return res if flag == 1 else -res

